package com.interview.one.service.impl;

import com.interview.one.mapper.UserInfoMapper;
import com.interview.one.model.UserInfo;
import com.interview.one.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo getUserById(int paramInt) {
        return userInfoMapper.selectByPrimaryKey(paramInt);
    }

    @Override
    public UserInfo getUserByMobile(String paramString) {
        Example userExample = new Example(UserInfo.class);
        Example.Criteria userCriteria = userExample.createCriteria();

        userCriteria.andEqualTo("userMobile", paramString);
        return userInfoMapper.selectOneByExample(userExample);
    }

    @Override
    public void addUser(UserInfo paramUserInfo) {
        userInfoMapper.insert(paramUserInfo);
    }

    @Override
    public int modifyUser(UserInfo paramUserInfo) {
        return userInfoMapper.updateByPrimaryKeySelective(paramUserInfo);
    }
}
